<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>核销确认提交页面</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 60px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
        <form id="repayForm">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_100" >
                    <div class="label">我司还款账户</div>
                    <div class="field">
                        <input name="repayAcc" id="repayAcc" type="text" class="ui-textbox" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
				<div class="fieldBox col_100">
                    <div class="label">银行流水号</div>
                    <div class="field">
                        <input name="bankNo" id="bankNo" type="text" class="ui-textbox" value="" >
                    </div>
                </div>
                
	             <div class="fieldBox col_100">
	                <div class="label">打款日期</div>
	                <div class="field">
	                	<input name="repayDate" id="repayDate" type="text" class="ui-datepicker" validate="{required:true}" ligerui="width: 115">
	                	<span class="requiredSymbol">*</span>
	                </div>
	            </div>
	              <div class="fieldBox col_100">
                    <div class="label">打款金额(元)</div>
                    <div class="field">
                        <input name="repayMoney" id="repayMoney" type="text" class="ui-textbox" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
	            
                 <div class="fieldBox col_100">
                    <div class="label">备注线下还款标识</div>
                    <div class="field">
                        <input name="repayMoneyRemark" id="repayMoneyRemark" type="text" class="ui-textbox" validate="{required:true}">
                        <span class="requiredSymbol">*</span>备注格式:yyyymmdd线下还款 注:备注日期与打款日期一致
                    </div>
                </div>
                <input name="batNos" id="batNos" type="hidden" value="${batNos}">
                <div class="btnsBox"></div>
        	</div>
        </form>
</div>
	<hr></hr>
	<h4>还款详情</h4>
	<tr >
		<td>本次线下还款笔数(笔)：<input name="repayAccountNum" id="repayAccountNum" type="text" value="${repayAccountNum}"  readonly="true"></td>
		<td>本次线下还款总金额(元)：<input name="repayAccountMoney" id="repayAccountMoney" type="text" value="${repayAccountMoney}"  readonly="true"></td>
	</tr>
	
	<br></br>
	<h5>还款明细列表</h5>
	<div id="ligergrid1" class="sq-grid"></div>
   <div class="btnsBox formBtns notRight">
          <span id="cancelBtn" class="sq-button sq-button-round">取消</span>
         <span id="confirmAndSubmit" class="sq-button sq-button-round">确认并提交</span>
   </div>

<script type="text/javascript">
var repayGrid = null;
$(function () {
    initGrid();//初始还款列表
    
  //确认并提交
    $("#confirmAndSubmit").click(function(event) {
        var ligerForm = liger.get("repayForm");
        if (!ligerForm.valid()) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        } 
        var data = ligerForm.getData();
        data["repayInfo"] = JSON.stringify(repayGrid.getData());//还款明细
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: '<%=path%>/mcr/mcrWriteOffConfirmSummary/confirmAndSubmit.do',
            beforeSend: function(){
                wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
            },
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    parent.location.reload();
                    frameElement.dialog.close();
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
        
    });
    
    $('#cancelBtn').click(function(){
    	frameElement.dialog.close();
    });

    
});

//初始化列表
function initGrid(){
    var batNos = $("#batNos").val();
    $("#ligergrid1").ligerGrid({
        // data: data,
        method:'get',
        url:'<%=path%>/mcr/mcrWriteOffConfirmSummary/confirmAndSubmitList.do?batNos='+batNos,
        columns:[
        	{ display: '批次号', name: 'batNo', width: 150, enabledSort:true },
            { display: '还款笔数', name: 'repayNum', width: 80, enabledSort:true},
            { display: '实收总金额(元)', name: 'repayAmt', width: 80, enabledSort:true},
            { display: '实收本金(元)', name: 'repayPrincipal', width: 80, enabledSort:true},
            { display: '实收利息(元)', name: 'repayInterest', width: 80, enabledSort:true},
            { display: '实收罚息(元)', name: 'repayPenaltyInterest', width: 80, enabledSort:true},
            getGridOperColumnContent()//操作列
        ],
        usePager: false,//是否有分页便签
        root:'rows',
        record:'total',
        hideLoadButton:false,
        width:'100%',
        height:'100%',
        heightDiff:-2,
        isScroll: false,//是否有滚动条
        checkbox:false,//列表是否有选择框
        enabledEdit: true,//是否能编辑
        rownumbers:true//列表是否有行号
    });
    repayGrid = liger.get("ligergrid1");
    $("#repayForm").ligerForm({
		validate: true
	});
}

//Grid操作列
function getGridOperColumnContent(){
	var data = {
            display: '操作',
            isSort: false,
            width: 200,
            render: function (rowdata, rowindex, value){
                var h='<a class="sq-button-hasicon" href="javascript:deletePage(';
                    h+="'"+rowdata.__id+"'";
                    h+=')"><i class="sqBtnIco_4"></i>删除</a>';
               
               	var i='<a class="sq-button-hasicon" href="javascript:checkDetails(';
                    i+="'"+rowdata.batNo+"'";
                    i+=')"><i class="sqBtnIco_4"></i>查看明细</a>';
               	var returnStr = h+i;  
               	return returnStr;
            }
        }
	return data;
}

//本地删除
function deletePage(rowdata_id) {
    $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
        if (flag == false) return;
        //删除页面
        repayGrid.deleteRow(rowdata_id);
    })
}

//查看明细
function checkDetails(batNo) {
	 $.ligerDialog.open({
         width: 800,
         height: 500,
         title: '明细',
         url: '<%=path%>/mcr/mcrWriteOffConfirmDetail/checkDetails.do?batNo='+batNo
     });
}

</script>

</body>
</html>
